<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="d1"></div>
<script>
    function f() {
        let n1 = new Date();
        let y = n1.getFullYear();
        let m = (n1.getMonth() + 1).toString().padStart(2, "0");
        let d = n1.getDate().toString().padStart(2, "0");
        let h = n1.getHours().toString().padStart(2, "0");
        let f = n1.getMinutes().toString().padStart(2, "0");
        let s = n1.getSeconds().toString().padStart(2, "0");

        let apm = "AM";
        if (h > 12) {
            h = h - 12;
            apm = "PM";
        }
        let weekday = 0;
        switch (n1.getDay()) {
            case 0:
                weekday = "星期日";
                break;
            case 1:
                weekday = "星期一";
                break;
            case 2:
                weekday = "星期二";
                break;
            case 3:
                weekday = "星期三";
                break;
            case 4:
                weekday = "星期四";
                break;
            case 5:
                weekday = "星期五";
                break;
            case 6:
                weekday = "星期六";
                break;
        }
        document.getElementById("d1").innerHTML = `${y}年${m}月${d}日  ${h}:${f}:${s} ${apm} ${weekday}`;
    }

    setInterval(f, 1000);
</script>
</body>
</html>